import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import * as filters from './untils/filter';
import plugins from './untils/plugins'
import {
  Button, Icon, Tabbar, TabbarItem, Field, Lazyload, Swipe, SwipeItem, DropdownMenu, DropdownItem, List, PullRefresh, Dialog, Calendar, DatetimePicker, Popup, Picker, Area, Toast, Tab, Tabs, Cell
} from 'vant';
import 'lib-flexible'
import FastClick from 'fastclick'
import VueDND from 'awe-dnd'//vue中的拖拽排序插件

Vue.use(VueDND)

FastClick.attach(document.body)

Vue.use(Button).use(Icon).use(Tabbar).use(TabbarItem).use(Field).use(Lazyload).use(Swipe).use(SwipeItem).use(DropdownMenu).use(DropdownItem).use(List).use(PullRefresh).use(Dialog).use(Calendar).use(DatetimePicker).use(Popup).use(Picker).use(Area).use(Toast).use(Tab).use(Tabs).use(Cell);
Vue.config.productionTip = false

// 登陆前验证
router.beforeEach((to, from, next) => {
  document.title = `${to.meta.title}`;
  const role = localStorage.getItem('username');
  if (!role && to.meta.login_require) {
    next('/login');
  }
  next()
});
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
Vue.prototype.$pub = plugins;


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
